package mortal.game.control
{
    import Message.Game.*;
    import Message.Public.*;
    import com.gengine.global.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import modules.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.proxy.*;
    import mortal.game.resource.info.*;
    import mortal.game.view.pack.*;
    import mortal.game.view.pack.define.*;
    import mortal.game.view.wareHouse.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class WareHouseController extends Controller
    {
        public const posType:int = 1;
        public const extendPosType:int = 6;
        private var _wareHouseModule:WareHouseModule;
        private var _wareHouseCache:WareHousePosTypeCache;
        private var _wareHouseExtendCache:WareHouseExtendPosTypeCache;
        private var _wareHouseProxy:WareHouseProxy;
        private var _wareHouseExtendProxy:WareHouseExtendProxy;
        private var _packProxy:PackProxy;
        private var _packCache:PackPosTypeCache;
        public var chooseAllLabel:Boolean = true;
        private var dataProvider:DataProvider;
        private var _wareHouseArray:Array;
        private var tabBarSelect_title:Object = 0;
        private var page:int;

        public function WareHouseController()
        {
            this._wareHouseProxy = new WareHouseProxy();
            this._wareHouseExtendProxy = new WareHouseExtendProxy();
            this._packProxy = new PackProxy();
            this._wareHouseCache = Cache.instance.pack.wareHousePackCache;
            this._packCache = Cache.instance.pack.backPackCache;
            this._wareHouseExtendCache = Cache.instance.pack.wareHouseExtendPackCache;
            
        }

        override protected function initView() : IView
        {
            if (!this._wareHouseModule)
            {
                this._wareHouseModule = new WareHouseModule();
                this._wareHouseModule.addEventListener(Event.ADDED_TO_STAGE, this.addToStage);
                this._wareHouseModule.addEventListener(EventName.WarePageTabBarSelect, this.pageTabBarSelect);
                this._wareHouseModule.addEventListener(EventName.WareTabBarSelect, this.tabBarSelect);
            }
            return this._wareHouseModule;
        }

        override protected function initServer() : void
        {
            Dispatcher.addEventListener(EventName.WareHouse_DragInItem, this.dragInItem);
            Dispatcher.addEventListener(EventName.WareHouse_Tity, this.tidy);
            Dispatcher.addEventListener(EventName.WareHouse_TakeOut, this.takeOut);
            Dispatcher.addEventListener(EventName.Fast_USE_WareHousePackage, this.fastUsePackage);
            Dispatcher.addEventListener(EventName.Fast_Move_wareHouseItem_ToPack, this.fastMoveItemToPack);
            Dispatcher.addEventListener(EventName.OpenWareHouseExtendItem, this.openWareHouseExtendItem);
            Dispatcher.addEventListener(EventName.WareHouse_DragInExtendItem, this.wareHouse_DragInExtendItem);
            Dispatcher.addEventListener(EventName.StorageOpen, this.storageOpenHandler);
            Dispatcher.addEventListener(EventName.VIPStorageOpen, this.vipStorageOpenHandler);
            Dispatcher.addEventListener(EventName.AI_NpcOutDestance, this.npcOutHandler);
            NetDispatcher.addCmdListener(ServerCommand.WareHouseCapacityChange, this.updateCapacityChange);
            NetDispatcher.addCmdListener(ServerCommand.WareHouseDataChange, this.updateDataChange);
            NetDispatcher.addCmdListener(ServerCommand.WareHouseItemsChange, this.updateItems);
            NetDispatcher.addCmdListener(ServerCommand.WareHouseExtendItemsChange, this.updateExtendDataChange);
            NetDispatcher.addCmdListener(ServerCommand.WareHouseExtendDataChange, this.updateExtendDataChange);
            
        }

        private function addToStage(event:Event) : void
        {
            this._wareHouseProxy.getBag();
            if (GameController.pack.view.isHide)
            {
                GameController.pack.view.show();
            }
            this.updateExtendDataChange(null);
            
        }

        private function tabBarSelect(event:DataEvent) : void
        {
            this.tabBarSelect_title = event.data;
            this.updateAllItems();
            
        }

        private function updateAllItems(param1:Boolean = true) : void
        {
            var _loc_3:SBag = null;
            var _loc_4:Array = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:Object = null;
            this.dataProvider = new DataProvider();
            var _loc_2:* = this._wareHouseCache._allItems.length;
            if (this._wareHouseCache)
            {
                switch(this.tabBarSelect_title)
                {
                    case 0:
                    {
                        this.chooseAllLabel = true;
                        _loc_4 = this._wareHouseCache.getItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                        break;
                    }
                    case 1:
                    {
                        this.chooseAllLabel = false;
                        _loc_4 = this._wareHouseCache.getPropItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                        break;
                    }
                    case 2:
                    {
                        this.chooseAllLabel = false;
                        _loc_4 = this._wareHouseCache.getEquipItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                        break;
                    }
                    case 3:
                    {
                        this.chooseAllLabel = false;
                        _loc_4 = this._wareHouseCache.getJewelItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                        break;
                    }
                    default:
                    {
                        this.chooseAllLabel = false;
                        _loc_4 = new Array();
                        break;
                        break;
                    }
                }
                _loc_5 = _loc_4.length;
                _loc_6 = 0;
                while (_loc_6 < _loc_5)
                {
                    
                    _loc_7 = this.getDataObjectByItemData(_loc_4[_loc_6] as ItemData);
                    this.dataProvider.addItem(_loc_7);
                    _loc_6++;
                }
            }
            this._wareHouseModule._wareHouseItemPanel.updateAllItem(this.dataProvider, param1);
            
        }

        private function getDataObjectByItemData(param1:ItemData) : Object
        {
            var _loc_2:* = new Object();
            if (param1 == ItemData.nullItemData)
            {
                _loc_2.source = GlobalClass.getBitmap("NoHole");
                _loc_2.isOpened = false;
            }
            else if (param1)
            {
                _loc_2.itemData = param1;
                _loc_2.source = param1.itemInfo.url;
                _loc_2.isOpened = true;
            }
            else
            {
                _loc_2.isOpened = true;
            }
            return _loc_2;
        }

        private function pageTabBarSelect(event:DataEvent) : void
        {
            var _loc_2:* = this._wareHouseModule.tabDict;
            _loc_2[this._wareHouseModule.tabBarSelect] = this._wareHouseModule.pageTabBarSelect;
            this.updateAllItems();
            
        }

        override public function popup() : void
        {
            
        }

        private function updateDataChange(param1:Object = null) : void
        {
            var _loc_2:Array = null;
            var _loc_6:Object = null;
            if (!_view)
            {
                
            }
            this.dataProvider = new DataProvider();
            switch(this.tabBarSelect_title)
            {
                case 0:
                {
                    _loc_2 = this._wareHouseCache.getItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                    break;
                }
                case 1:
                {
                    _loc_2 = this._wareHouseCache.getPropItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                    break;
                }
                case 2:
                {
                    _loc_2 = this._wareHouseCache.getEquipItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                    break;
                }
                case 3:
                {
                    _loc_2 = this._wareHouseCache.getJewelItemsAtPage((this._wareHouseModule.pageTabBarSelect + 1), 30);
                    break;
                }
                case 4:
                {
                    _loc_2 = new Array();
                    break;
                }
                default:
                {
                    _loc_2 = new Array();
                    break;
                    break;
                }
            }
            var _loc_3:* = _loc_2.length;
            var _loc_4:int = 0;
            while (_loc_4 < _loc_2.length)
            {
                
                _loc_6 = this.getDataObjectByItemData(_loc_2[_loc_4] as ItemData);
                this.dataProvider.addItem(_loc_6);
                _loc_4++;
            }
            this._wareHouseModule.updateAllItems(this.dataProvider);
            this._wareHouseModule.updateCapacity(this._wareHouseCache);
            if (param1)
            {
                if (param1["selectIndex"] != -1)
                {
                    this._wareHouseModule.updateWareHouseItemPanelSelectItem((param1["selectIndex"] - 1));
                }
                else
                {
                    this._wareHouseModule.updateWareHouseItemPanelSelectItem(-1);
                }
            }
            var _loc_5:* = Cache.instance.pack.wareHousePackCache;
            
        }

        private function dragInItem(event:DataEvent) : void
        {
            var _loc_8:ItemData = null;
            var _loc_9:ItemData = null;
            var _loc_10:ItemData = null;
            var _loc_11:int = 0;
            var _loc_12:Boolean = false;
            var _loc_13:* = undefined;
            this.page = this._wareHouseModule.pageTabBarSelect;
            var _loc_2:* = event.data as DragDropData;
            var _loc_3:* = _loc_2.fromPosType;
            var _loc_4:* = _loc_2.fromIndex;
            var _loc_5:* = _loc_2.toIndex;
            var _loc_6:* = _loc_2.uid;
            var _loc_7:* = _loc_2.toPosType;
            switch(_loc_3)
            {
                case 0:
                {
                    _loc_4 = this._packCache.getIndexByUid(_loc_6);
                    _loc_5 = 30 * this.page + _loc_5;
                    _loc_2.fromIndex = _loc_4;
                    _loc_2.toIndex = _loc_5;
                    if (_loc_5 <= Cache.instance.pack.wareHousePackCache.sbag.capacity)
                    {
                        this._wareHouseProxy.move(_loc_2);
                    }
                    break;
                }
                case 1:
                {
                    _loc_4 = Cache.instance.pack.wareHousePackCache.getIndexByUid(_loc_6);
                    _loc_5 = 30 * this.page + _loc_5;
                    _loc_13 = Cache.instance.pack.wareHousePackCache;
                    if (_loc_5 <= Cache.instance.pack.wareHousePackCache.sbag.capacity)
                    {
                        this._wareHouseProxy.moveInBag(_loc_6, _loc_5, _loc_4);
                    }
                    break;
                }
                case 3:
                {
                    break;
                }
                case 5:
                {
                    _loc_4 = Cache.instance.pack.backPackExtendPackCache.getIndexByUid(_loc_6);
                    _loc_5 = 30 * this.page + _loc_5;
                    _loc_9 = Cache.instance.pack.backPackExtendPackCache.getItemDataByIndex(_loc_4);
                    _loc_8 = Cache.instance.pack.wareHousePackCache.getItemDataByIndex(_loc_5);
                    this.moveExtendItem(_loc_2, this._wareHouseProxy);
                    break;
                }
                case 6:
                {
                    _loc_4 = Cache.instance.pack.wareHouseExtendPackCache.getIndexByUid(_loc_6);
                    _loc_5 = 30 * this.page + _loc_5;
                    _loc_9 = Cache.instance.pack.wareHouseExtendPackCache.getItemDataByIndex(_loc_4);
                    _loc_8 = Cache.instance.pack.wareHousePackCache.getItemDataByIndex(_loc_5);
                    this.moveExtendItem(_loc_2, this._wareHouseProxy);
                    break;
                }
                default:
                {
                    break;
                }
            }
            
        }

        public function tidy(event:DataEvent) : void
        {
            this._wareHouseProxy.tidy();
            
        }

        private function takeOut(event:DataEvent) : void
        {
            var _loc_3:ItemData = null;
            var _loc_4:ItemData = null;
            var _loc_5:String = null;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_9:int = 0;
            var _loc_10:Array = null;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            var _loc_13:DragDropData = null;
            var _loc_2:* = this._wareHouseModule._wareHouseItemPanel.selectedIndex;
            if (_loc_2 >= 0)
            {
                _loc_3 = this._wareHouseModule._wareHouseItemPanel.selectedItem.itemData;
                _loc_4 = this._wareHouseModule._wareHouseItemPanel.selectedItem.itemData;
                if (!_loc_4)
                {
                    
                }
                _loc_5 = _loc_4.uid;
                _loc_6 = 1;
                _loc_7 = 0;
                _loc_8 = this._wareHouseModule._wareHouseItemPanel.selectedIndex;
                _loc_9 = Cache.instance.pack.backPackCache.itemLength;
                _loc_10 = Cache.instance.pack.backPackCache.getAllItems();
                _loc_11 = 0;
                while (_loc_11 < _loc_10.length)
                {
                    
                    if (!Cache.instance.pack.backPackCache.getItemDataByIndex((_loc_11 + 1)))
                    {
                        _loc_12 = Cache.instance.pack.wareHousePackCache.getIndexByUid(_loc_5);
                        _loc_13 = new DragDropData(_loc_6, _loc_7, _loc_5, _loc_12, (_loc_11 + 1), _loc_4, null);
                        GameProxy.packProxy.move(_loc_13);
                        
                    }
                    _loc_11++;
                }
            }
            else
            {
                
            }
            
        }

        private function updateItems(param1:Object) : void
        {
            var _loc_5:Object = null;
            if (!_view)
            {
                
            }
            this.updateDataChange();
            
            this._wareHouseModule.updateItem(this.dataProvider);
            this._wareHouseModule.updateCapacity(Cache.instance.pack.wareHousePackCache);
            if (param1)
            {
                if (param1["selectIndex"] != -1)
                {
                    this._wareHouseModule.updateWareHouseItemPanelSelectItem((param1["selectIndex"] - 1));
                }
                else
                {
                    this._wareHouseModule.updateWareHouseItemPanelSelectItem(-1);
                }
            }
            
        }

        private function wareHouse_DragInExtendItem(event:DataEvent) : void
        {
            var _loc_4:int = 0;
            var _loc_9:ItemData = null;
            var _loc_10:ItemData = null;
            var _loc_11:int = 0;
            var _loc_12:Boolean = false;
            var _loc_2:* = event.data as DragDropData;
            var _loc_3:* = _loc_2.fromPosType;
            var _loc_5:* = _loc_2.toIndex;
            var _loc_6:* = _loc_2.uid;
            var _loc_7:* = _loc_2.toPosType;
            var _loc_8:* = Cache.instance.pack.getPackChacheByPosType(_loc_7).getItemDataByIndex(_loc_5) as ItemData;
            switch(_loc_3)
            {
                case 0:
                {
                    _loc_4 = _loc_2.fromIndex + 30 * GameController.pack.packModule.pageTabBarSelect;
                    _loc_9 = Cache.instance.pack.getPackChacheByPosType(_loc_3).getItemDataByIndex(_loc_4) as ItemData;
                    this.moveExtendItem(_loc_2, this._wareHouseExtendProxy);
                    break;
                }
                case 1:
                {
                    _loc_4 = _loc_2.fromIndex + 30 * this.page;
                    _loc_9 = Cache.instance.pack.getPackChacheByPosType(_loc_3).getItemDataByIndex(_loc_4) as ItemData;
                    this.moveExtendItem(_loc_2, this._wareHouseExtendProxy);
                    break;
                }
                case 5:
                {
                    _loc_4 = _loc_2.fromIndex;
                    _loc_9 = Cache.instance.pack.getPackChacheByPosType(_loc_3).getItemDataByIndex(_loc_4) as ItemData;
                    this.moveExtendItem(_loc_2, this._wareHouseExtendProxy);
                    break;
                }
                case 6:
                {
                    _loc_4 = _loc_2.fromIndex;
                    _loc_9 = Cache.instance.pack.getPackChacheByPosType(_loc_3).getItemDataByIndex(_loc_4) as ItemData;
                    if (_loc_5 <= Cache.instance.pack.wareHouseExtendPackCache.sbag.capacity)
                    {
                        this._wareHouseExtendProxy.moveInBag(_loc_6, _loc_5, _loc_4);
                    }
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            
        }

        private function moveExtendItem(param1:DragDropData, param2) : void
        {
            var len:int;
            var toItemIsExtend:Boolean;
            var _cache:*;
            var _proxy:*;
            var toItemCategory:int;
            var toItemProp:int;
            var toIndex:int;
            var isTidy:Boolean;
            var pathOfDrag:String;
            var dragDropData:* = param1;
            var proxy:* = param2;
            var showAlterWindow:* = function (param1:String, param2:Boolean, param3:String = null) : void
            {
                var posName:* = param1;
                var _isTidy:* = param2;
                var path:* = param3;
                if (_cache.getLengthOfNullItemFromAllItem() >= len)
                {
                    var closeHandler1:* = function (param1:int) : void
                {
                    if (param1 == Alert.YES)
                    {
                        if (toIndex <= _cache.sbag.capacity)
                        {
                            _proxy.move(dragDropData, _isTidy, path);
                        }
                    }
                    
                }
                ;
                    Alert.show("确定将会重新整理" + posName, null, Alert.YES | Alert.CANCEL, null, closeHandler1);
                }
                else
                {
                    MsgManager.addBroadCast(posName + "容量不足！");
                }
                
            }
            ;
            var toItemData:* = dragDropData.toItemData;
            var fromItemData:* = dragDropData.fromItemData;
            var fromIndex:* = dragDropData.fromIndex;
            toIndex = dragDropData.toIndex;
            var fromPosType:* = dragDropData.fromPosType;
            var toPosType:* = dragDropData.toPosType;
            var uid:* = dragDropData.uid;
            if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar)
            {
                if (toIndex <= Cache.instance.pack.backPackExtendPackCache.sbag.capacity)
                {
                    this._wareHouseExtendProxy.move(dragDropData);
                }
            }
            if (toItemData == null)
            {
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar)
                {
                    GameProxy.wareHouseExtendProxy.move(dragDropData);
                    
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBag && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar)
                {
                    GameProxy.wareHouseExtendProxy.move(dragDropData);
                    
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse)
                {
                    _cache = Cache.instance.pack.backPackCache;
                    _proxy = GameProxy.packProxy;
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse)
                {
                    _cache = Cache.instance.pack.wareHousePackCache;
                    _proxy = GameProxy.wareHouseProxy;
                    toItemIsExtend;
                    len = (fromItemData.itemInfo.item.effect + 1);
                    this.showAlterWindow("仓库", true);
                }
            }
            else
            {
                toItemCategory = toItemData.itemInfo.item.category;
                toItemProp = toItemData.itemInfo.item.type;
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse)
                {
                    _cache = Cache.instance.pack.wareHousePackCache;
                    _proxy = GameProxy.wareHouseProxy;
                    if (toItemCategory == ECategory._ECategoryProp && toItemProp == EProp._EPropPackage)
                    {
                        pathOfDrag = BackPackWareHouseMoveType.WareHouseExtendToWareHouse;
                        len = fromItemData.itemInfo.item.effect - toItemData.itemInfo.item.effect;
                        toItemIsExtend;
                    }
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar)
                {
                    _cache = Cache.instance.pack.wareHousePackCache;
                    _proxy = GameProxy.wareHouseProxy;
                    if (toItemCategory == ECategory._ECategoryProp && toItemProp == EProp._EPropPackage)
                    {
                        pathOfDrag = BackPackWareHouseMoveType.WareHouseToWareHouseExtend;
                        toItemIsExtend;
                        len = fromItemData.itemInfo.item.effect - toItemData.itemInfo.item.effect;
                    }
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBag && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar)
                {
                    _cache = Cache.instance.pack.backPackCache;
                    _proxy = GameProxy.packProxy;
                    if (toItemCategory == ECategory._ECategoryProp && toItemProp == EProp._EPropPackage)
                    {
                        pathOfDrag = BackPackWareHouseMoveType.BackPackToWareHouseExtend;
                        toItemIsExtend;
                        len = fromItemData.itemInfo.item.effect - toItemData.itemInfo.item.effect;
                    }
                }
                if (fromPosType == EPlayerItemPosType._EPlayerItemPosTypeBagExtendBar && toPosType == EPlayerItemPosType._EPlayerItemPosTypeWarehouse)
                {
                    _cache = Cache.instance.pack.wareHousePackCache;
                    _proxy = GameProxy.wareHouseProxy;
                    if (toItemCategory == ECategory._ECategoryProp && toItemProp == EProp._EPropPackage)
                    {
                        pathOfDrag = BackPackWareHouseMoveType.BackPackExtendToWareHouse;
                        toItemIsExtend;
                        len = fromItemData.itemInfo.item.effect - toItemData.itemInfo.item.effect;
                    }
                }
            }
            switch(pathOfDrag)
            {
                case BackPackWareHouseMoveType.WareHouseToWareHouseExtend:
                {
                    if (toIndex <= _cache.sbag.capacity)
                    {
                        if (len >= 0)
                        {
                            isTidy;
                            _proxy.move(dragDropData);
                        }
                        else
                        {
                            isTidy;
                            this.showAlterWindow("仓库", isTidy);
                        }
                    }
                    break;
                }
                case BackPackWareHouseMoveType.WareHouseExtendToWareHouse:
                {
                    if (toIndex <= _cache.sbag.capacity)
                    {
                        if (len > 0)
                        {
                            isTidy;
                            this.showAlterWindow("仓库", isTidy);
                        }
                        else
                        {
                            isTidy;
                            _proxy.move(dragDropData);
                        }
                    }
                    break;
                }
                case BackPackWareHouseMoveType.BackPackExtendToWareHouse:
                {
                    if (toIndex <= _cache.sbag.capacity)
                    {
                        if (len > 0)
                        {
                            isTidy;
                            this.showAlterWindow("背包", isTidy, BackPackWareHouseMoveType.BackPackExtendToWareHouse);
                        }
                        else
                        {
                            isTidy;
                            _proxy.move(dragDropData, isTidy, BackPackWareHouseMoveType.BackPackExtendToWareHouse);
                        }
                    }
                    break;
                }
                case BackPackWareHouseMoveType.BackPackToWareHouseExtend:
                {
                    if (toIndex <= _cache.sbag.capacity)
                    {
                        if (len >= 0)
                        {
                            isTidy;
                            _proxy.move(dragDropData, false, BackPackWareHouseMoveType.BackPackToWareHouseExtend);
                        }
                        else
                        {
                            isTidy;
                            this.showAlterWindow("仓库", isTidy, BackPackWareHouseMoveType.BackPackToWareHouseExtend);
                        }
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            
        }

        private function updateExtendDataChange(param1:Object = null) : void
        {
            var _loc_6:Object = null;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            var _loc_2:* = param1;
            if (!_view)
            {
                
            }
            var _loc_3:* = new DataProvider();
            var _loc_4:* = Cache.instance.pack.wareHouseExtendPackCache.getAllItems();
            var _loc_5:* = Cache.instance.pack.wareHouseExtendPackCache.getAllItems().length;
            if (_loc_4.length <= 6)
            {
                _loc_7 = 0;
                while (_loc_7 < _loc_4.length)
                {
                    
                    _loc_6 = this.getDataObjectByExtendItemData(_loc_4[_loc_7] as ItemData);
                    _loc_3.addItem(_loc_6);
                    _loc_7++;
                }
                _loc_8 = 0;
                while (_loc_8 < 6 - _loc_4.length)
                {
                    
                    _loc_6 = new Object();
                    _loc_6.source = GlobalClass.getBitmap("NoHole");
                    _loc_6.isOpened = false;
                    _loc_3.addItem(_loc_6);
                    _loc_8++;
                }
                this._wareHouseModule.updateExtendAllItems(_loc_3);
                if (param1)
                {
                    if (param1["selectIndex"] != -1)
                    {
                        this._wareHouseModule.updateWareHouseExtendItemPanelSelectItem((param1["selectIndex"] - 1));
                    }
                    else
                    {
                        this._wareHouseModule.updateWareHouseExtendItemPanelSelectItem(-1);
                    }
                }
            }
            
        }

        private function getDataObjectByExtendItemData(param1:ItemData) : Object
        {
            var _loc_2:* = new Object();
            if (param1 == ItemData.nullItemData)
            {
                _loc_2.source = GlobalClass.getBitmap("NoHole");
                _loc_2.isOpened = false;
            }
            else if (param1)
            {
                _loc_2.itemData = param1;
                _loc_2.source = param1.itemInfo.url;
                _loc_2.isOpened = true;
            }
            else
            {
                _loc_2.isOpened = true;
            }
            return _loc_2;
        }

        private function updateCapacityChange(param1:Object) : void
        {
            var _loc_2:* = Cache.instance.pack.wareHousePackCache.capacity;
            var _loc_3:* = param1 as SBagCapacityChangeMsg;
            var _loc_4:* = Math.abs(_loc_3.newCapacity - _loc_2);
            if (_loc_3.newCapacity > _loc_2)
            {
                Cache.instance.pack.wareHousePackCache.addNullItemToEnd(_loc_4);
                this.updateItems(new Array());
            }
            Cache.instance.pack.wareHousePackCache.capacity = _loc_3.newCapacity;
            this._wareHouseModule.updateCapacity(Cache.instance.pack.wareHousePackCache);
            
        }

        private function vipStorageOpenHandler(event:DataEvent) : void
        {
            view.show();
            GameController.pack.view.show();
            (view as DisplayObject).x = (Global.stage.stageWidth - (view as DisplayObject).width - (GameController.pack.view as DisplayObject).width - 5) / 2;
            (GameController.pack.view as DisplayObject).x = (view as DisplayObject).x + (view as DisplayObject).width + 5;
            
        }

        private function storageOpenHandler(event:DataEvent) : void
        {
            view.show();
            GameController.pack.view.show();
            (view as DisplayObject).x = (Global.stage.stageWidth - (view as DisplayObject).width - (GameController.pack.view as DisplayObject).width - 5) / 2;
            (GameController.pack.view as DisplayObject).x = (view as DisplayObject).x + (view as DisplayObject).width + 5;
            this._wareHouseModule.checkGuide();
            
        }

        private function npcOutHandler(event:DataEvent) : void
        {
            if (!view.isHide)
            {
                view.hide();
                if (!GameController.pack.view.isHide)
                {
                    GameController.pack.view.hide();
                }
            }
            
        }

        public function get wareHouseModule() : WareHouseModule
        {
            return this._wareHouseModule;
        }

        private function fastUsePackage(event:DataEvent) : void
        {
            var _loc_8:DragDropData = null;
            var _loc_2:* = event.data as WareHouseItem;
            if (!_loc_2.itemData)
            {
                
            }
            var _loc_3:* = _loc_2.itemData.uid;
            var _loc_4:* = EPlayerItemPosType._EPlayerItemPosTypeWarehouse;
            var _loc_5:* = EPlayerItemPosType._EPlayerItemPosTypeWarehouseExtendBar;
            var _loc_6:* = Cache.instance.pack.wareHousePackCache.getIndexByUid(_loc_3);
            var _loc_7:* = Cache.instance.pack.wareHousePackCache.getFirstNullItemIndex();
            if (Cache.instance.pack.wareHousePackCache.getFirstNullItemIndex() != -1)
            {
                _loc_8 = new DragDropData(_loc_4, _loc_5, _loc_3, _loc_6, (_loc_7 + 1), null, null);
                GameProxy.wareHouseProxy.move(_loc_8);
            }
            else
            {
                MsgManager.addBroadCast("仓库扩展槽已满！");
            }
            
        }

        private function fastMoveItemToPack(event:DataEvent) : void
        {
            var _loc_9:DragDropData = null;
            var _loc_2:* = event.data as WareHouseItem;
            if (!_loc_2.itemData)
            {
                
            }
            var _loc_3:* = this._wareHouseModule.getWareHouseItemPanelSelectItem().itemData;
            var _loc_4:* = _loc_3.uid;
            var _loc_5:* = EPlayerItemPosType._EPlayerItemPosTypeWarehouse;
            var _loc_6:* = EPlayerItemPosType._EPlayerItemPosTypeBag;
            var _loc_7:* = Cache.instance.pack.wareHousePackCache.getIndexByUid(_loc_2.itemData.uid);
            var _loc_8:* = Cache.instance.pack.backPackCache.getFirstNullItemIndex();
            if (Cache.instance.pack.backPackCache.getFirstNullItemIndex() != -1)
            {
                _loc_9 = new DragDropData(_loc_5, _loc_6, _loc_4, _loc_7, (_loc_8 + 1), null, null);
                GameProxy.packProxy.move(_loc_9);
            }
            else
            {
                MsgManager.addBroadCast("背包已满！");
            }
            
        }

        private function openWareHouseExtendItem(event:DataEvent) : void
        {
            GameProxy.wareHouseExtendProxy.openExtendItem(PackCache.Type_WareHouseExtend);
            
        }

    }
}
